//
//  QDashLineView.m
//  QMCXDriver
//
//  Created by Massimo on 2017/4/13.
//  Copyright © 2017年 Massimo. All rights reserved.
//

#import "QDashLineView.h"
#define LineCorlor LLColorRGB(225,225,226)


//IB_DESIGNABLE
@implementation QDashLineView
- (void)awakeFromNib{
    [super awakeFromNib];
    self.backgroundColor = [UIColor clearColor];
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    
    CGFloat scale = [UIScreen mainScreen].scale;
    // Drawing code
    CGContextRef currentContext = UIGraphicsGetCurrentContext();
    
    //设置虚线颜色`
    CGContextSetStrokeColorWithColor(currentContext,LineCorlor.CGColor);
    //设置虚线宽度
    CGContextSetLineWidth(currentContext, 1*scale);
    //设置虚线绘制起点
    CGContextMoveToPoint(currentContext, 0, 0);
    //设置虚线绘制终点
    CGContextAddLineToPoint(currentContext, self.frame.origin.x + self.frame.size.width, 0);
    //设置虚线排列的宽度间隔:下面的arr中的数字表示先绘制3个点再绘制1个点
    CGFloat arr[] = {6,3};
    //下面最后一个参数“2”代表排列的个数。
    CGContextSetLineDash(currentContext, 0, arr, 2);
    CGContextDrawPath(currentContext, kCGPathStroke);
}

@end
